home *** CD-ROM | disk | FTP | other *** search
- #!/bin/csh -f
- #
- # $Id: stop 1.2 1997/02/12 16:31:24 mma Exp $
- #
- # Copyright (c) 1991-1997, Inso Corporation
- # All Rights Reserved.
- #
- #
- # Usage: stop|restart [service]
- #
- # This script stops (or restarts) the specified dynaweb service (as
- # defined in the dwhttpd.cfg file).
- #
- # The action (stop or restart) taken by this script is determined by the
- # script's name. If the script is named "restart", the selected service
- # (or services) will be sent the restart signal. Any other name for this
- # script causes a quit signal to be sent to the desired service(s).
- #
- # If the service parameter is absent the main server controller is
- # signaled. When this process is stopped all subordinate protocol
- # modules will terminate.
- #
- # If a service name (or regexp) is provided, only the services whose
- # name matches the regexp will be signaled accordingly.
- #
- #####################################################################
-
- #
- # Determine which command we're running. We need to know this so we
- # can determine which signal to send at our target.
- #
-
- set cmdname = $0
- set cmdname=`echo $cmdname:t`
-
- #
- # See if the user has specified where the pid file is located. If
- # not, use a suitable default and check to see that it exists.
- #
-
- if ($?DWEB_PIDLOG) then
- set pidlog=$DWEB_PIDLOG
- else
- set pidlog=pid.log
- endif
-
- if (! -e $pidlog) then
- echo "Unable to open '${pidlog}'. Is the server running?"
- exit
- endif
-
-
- #
- # Check for the service name that the user wants to blow away. If
- # one isn't specified, nail the server-controller process.
- #
-
- if ($#argv < 1) then
- set target=server-controller
- else
- set target=$argv[1]
- endif
-
-
- #
- # Find the pid to nuke!
- #
-
- set pid=(`grep $target pid.log | awk '{print $1}'`)
-
-
- #
- # Check to see if we could we find the pid. If not, give the user a list.
- #
-
- if ($#pid == 0) then
- echo 'Invalid service name\! Please select one of: '
- awk '{printf "\t%s\n", $2}' $pidlog
- exit
- endif
-
-
- #
- # Determine which signal to send to the process based on which
- # operation we're performing (e.g. stop, restart)
- #
-
- if ($cmdname == "restart") then
- set signal=1
- else
- set signal=3
- endif
-
-
- #
- # Finally, nail the process
- #
-
- kill -$signal $pid
-
-
-